﻿using monitoring_system.Share;
using Prism.Commands;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace monitoring_system.ViewModels
{
    public class ShellViewModel
    {
        /// <summary>
        /// 依赖注入容器用来管理对象的创建和生命的周期
        /// </summary>
        private IContainerExtension container;
        public ICommand LoadedCommand { get; }
        public ShellViewModel(IContainerExtension containerExtension)
        {
            container=containerExtension;
            LoadedCommand = new DelegateCommand(OnLoadedCommand);
        }
        private void OnLoadedCommand()
        {
            //IRegionManager:允许开发者在不同的视图之间进行导航，而无需直接依赖具体的视图
            container.Resolve<IRegionManager>().RequestNavigate(RegionNames.MainRegion, ViewNames.LoginView);
        }
    }
}
